<template>
    <div>
        <Card :bordered="false" dis-hover class="ivu-mt">
            <Button type="primary" @click="handleAllocation">新增</Button>
            <Table highlight-row :columns="columns" :data="data" class="ivu-mt-16">
                <template slot-scope="{ row }" slot="status">
                     <Badge v-if="row.status ==='1'" status="success" text="正常" />
                    <Badge v-if="row.status ==='0'" status="error" text="停用" />
                </template>
                <template slot-scope="{ row }" slot="operation">
                    <a @click="handleAllocation">编辑</a>
                </template>
            </Table>
            <div class="ivu-mt iuv-text-center">
                <Page :total="100" show-total />
            </div>
        </Card>
        <Modal v-model="modal" title="新增" @on-ok="handleSubmit" @on-cancel="handleDrawerCancel">
            <Form :model="formItem" :label-width="100">
                <FormItem label="名称" required>
                    <Input v-model="formItem.input" placeholder="请输入"></Input>
                </FormItem>
               <FormItem label="负责人">
                    <Select v-model="formItem.director" multiple>
                        <Option value="高玲">高玲</Option>
                        <Option value="时宜">时宜</Option>
                        <Option value="王艳">王艳</Option>
                    </Select>
                </FormItem>
                <FormItem label="关联白友项目">
                    <Select v-model="formItem.project">
                        <Option value="高玲">HFY</Option>
                        <Option value="时宜">HFX</Option>
                        <Option value="王艳">NT</Option>
                    </Select>
                </FormItem>
                <FormItem label="状态">
                    <i-switch v-model="formItem.switch">
                        <span slot="open">On</span>
                        <span slot="close">Off</span>
                    </i-switch>
                </FormItem>
            </Form>
        </Modal>
    </div>
</template>

<script>
    export default {
        name: 'diagnosis',
        data () {
            return {
                modal: false,
                formItem: {
                    input: '',
                    switch: true,
                    project: '',
                    director: ''
                },
                columns: [
                    {
                        title: '名称',
                        key: 'name'
                    },
                    {
                        title: '项目负责人',
                        key: 'director'
                    },
                    {
                        title: '项目人数',
                        key: 'number'
                    },
                    {
                        title: '关联白友项目',
                        key: 'baiyou'
                    },
                    {
                        title: '状态',
                        slot: 'status'
                    },
                    {
                        title: '操作',
                        slot: 'operation'
                    }
                ],
                data: [
                    {
                        name: '合肥北大',
                        number: 3,
                        baiyou: 'FHX',
                        director: '张雨',
                        status: '0'
                    },
                    {
                        name: '华研',
                        number: 5,
                        baiyou: 'sz',
                        director: '建鹏/时宜',
                        status: '1'
                    },
                    {
                        name: '南通',
                        number: 9,
                        baiyou: 'NT',
                        director: '高玲',
                        status: '1'
                    }
                ]
            }
        },
        methods: {
            handleAllocation () {
                this.modal = true;
            },
            handleDrawerCancel () {
                this.$Message.warning('已取消!');
            },
            handleSubmit () {
                this.$Message.success('操作成功!');
            }
        }
    }
</script>

<style scoped>
</style>
